package com.BlogPark.config;

import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import java.util.ArrayList;
import java.util.List;

/**
 * @Auther: MFM
 * @Date: 2022/8/10 - 08 - 10 - 21:07
 * @version: 1.0
 */

public class SpringMvcSupport extends WebMvcConfigurationSupport {

    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/webapp/**").addResourceLocations("/webapp/");
    }

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        List<String> excludeList = new ArrayList<String>();
        excludeList.add("/appLogin/login");
        excludeList.add("/error");
        registry.addInterceptor(new LoginHandlerIntercepter()).addPathPatterns("/**").excludePathPatterns(excludeList);

//        registry.addInterceptor(new LoginHandlerIntercepter()).addPathPatterns("/**").excludePathPatterns("*.js")
//                .excludePathPatterns("*.html").excludePathPatterns("*.css").excludePathPatterns("/login")
//                .excludePathPatterns("/logout").excludePathPatterns("/index").excludePathPatterns("/");
        super.addInterceptors(registry);
    }
}
